// 引入events模块
const EventEmitter = require('events')
const eventEmitter = new EventEmitter()

// 定义一个Person类，继承自EventEmitter
class Person extends EventEmitter {

  // 构造函数，用于创建对象
  constructor(name) {
    super();
    this._name = name
  }

  // 获取name属性的getter方法
  get name() {
    return this._name;
  }
}

let person1 = new Person('zhangsan');
let person2 = new Person('lisi');

person1.on('event', () => {
  console.log('my name is: ' + person1.name);

}).emit('event')

person2.on('event', () => {
  console.log('my name is: ' + person2.name);

})
person2.emit('event')